package weaver.interfaces.jjy.duss.hr;

import com.sap.mw.jco.JCO;
import weaver.general.BaseBean;
import weaver.interfaces.jjy.duss.util.SAPComMehtod;
import weaver.interfaces.jjy.duss.util.SAPConnPool;

import java.util.HashMap;
import java.util.Map;


/**
 * @program: ecology-9-demo
 * @description: 查询通过身份证查询人员在sap中是否存在
 * @author: Dusongsong
 * @create: 2019-12-03
 */
public class HRSEL {
    JCO.Client myConnection = null;
    JCO.Function bapi = null;
    JCO.ParameterList input = null;
    JCO.ParameterList inputtable = null;
    public Map execute(Map<String,String> map) {
        try{
            SAPConnPool SAPConn = new SAPConnPool();
            myConnection = SAPConn.getConnection();
            bapi = SAPConn.excuteBapi("ZFM_HR_PERNR");
            input=bapi.getImportParameterList();//输入参数和结构处理
            inputtable= bapi.getTableParameterList();//输入表的处理
        }catch (Exception e){
            e.printStackTrace();
        }
        BaseBean baseBean = new BaseBean();
        //入参为字段
        input.setValue("SEL","JIEKNO");
        //入参为表
        JCO.Table t0= inputtable.getTable("PT0185");
        t0.appendRow();//追加行
        t0.setValue("01", "ICTYP");
        t0.setValue(map.get("ICNUM"), "ICNUM");
        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList  out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList  Table00 = bapi.getTableParameterList();//输出表的处理

        //返回处理结果以及日志
        Map<String,String> resultMap = new HashMap<String,String>();
        String[] tabs={"PT0185"};
        String[] str={"PS0000","PS0001","PS0002"};
        //resultMap = SAPConnPool.SAPreturn(str,out,tabs,Table00);
        resultMap = SAPComMehtod.SAPreturn(out,Table00);
        baseBean.writeLog(resultMap);
        System.out.println(resultMap.toString());
        JCO.releaseClient(myConnection);
        return resultMap;
    }

    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("ICNUM","522126199408174519");
        HRSEL hrsel = new HRSEL();
        hrsel.execute(map);

    }

}
